Rendering/ Scanline Hairs

Scanline Hairs

Scanline particles are ideally suited to small and thin objects such as hairs. The following tutorial demonstrates a typical workflow for creating hair:

Tutorial level: Advanced

Example project: 'tutorprojects/rendering/hairs'


A haircut modeled using 2D particles 

3D painting the hair base area

1. Load in the object 'models/nurbs/simple head' (or model the head yourself).

2. We start by texturing the hairy area of the head with a material that looks like hairs. This helps to keep the amount of 'real' hairs reasonably low. Select the loaded head object. Go to the 'Materials' tab of the toolbar and activate the UVimage tool. Define a suitable file name for storing the image, set color to black and press 'Accept'.


Options for Uvimage tool

3. Turn shaded OpenGL drawing on from the compass menu. Because of the attached black uvimage, the head appears black. Paint the area, which should be covered with hair, using the 3D painting tools (included in the 'Materials' tool tab). Use the tools as follows:

  • The paint color should be white. The image will be used later as a scope map, and white means 'fully hairy material'.
  • Paint the border of the hairy area with the airbrush tool to achieve a smooth gradient. You can reduce the hairy area by carefully brushing some black color.
  • You can fill the hairy area using the 'Curve' painting tool with the filled option set.
  • It may happen that some painting appears on the neck when you paint the top of the head. Don’t worry, this happens because the default UV space is not properly initialized. You can afterwards assign pointwise UV coordinates to the Nurbs model using the 'Define UV' tool, which appears to the tool control bar when the head is selected. Then open the UV Editor window, set the head to edit mode, select the lowest point row from the view window and move it slightly downwards in the UV editor.


The hairy area painted white

4. After painting, select the head, open the property window and go to the 'Col' tab. Clear the 'Texture' field, which contains the name of the painted image, and hit Enter. Set the 'Surface Properties/Color' gadget to a suitable skin color (e.g. light brown 1 0.8 0.7).

 

Materials for the hairy skin

5. Next we define the materials for the hairy skin. Three materials are needed for this purpose:

  • A material for hairy skin
  • A 'scope map' material which defines which part of the head is hairy
  • A level material combining the two above mentioned materials

Change the select window to show the material library. Select twice 'New/VSL Material' and once 'New/Level Material' from the select window's popup menu.

6. Select the first created VSL material. Rename it as 'hairbase'. Enable 'Advanced' options of the property window and add the following VSL objects to it:

  • A 'Surface properties' shader
  • A 'Constant' object that assigns a suitable hair color (e.g. dark brown 0.6 0.3 0.2)
  • A 'Cell' object, which adds irregular dark spots to the surface by scaling the color. Set 'Operation' to 'Multiply' from the popup menu. 'Minimum value' should be 1 and 'Amplitude' -0.4. This gives a range from 0.6 to 1 (in other words, darkest spots are 40 % darker than the base color). All 'Variation' fields should be set to a non-zero value, so that the pattern becomes irregular. See the picture below. Check the 1D option.


The base color of hairy skin is dark brown. Cell noise adds small darker spots to it.

7. Select the second blank VSL material. Rename it as 'HairArea'. Add a 'Surface properties' shader and a 'Texture' object to it. Set the output channel of the 'Texture' object to 'Surface:Scope' and input to 'Surface:UV coords'. Set the 'File' name gadget to the name of the image, which was initialized in the step 2 above and painted later. Other options are shown in the image below.


A scope map material for the hairy area

8. Select the 'Level' type material and rename it as 'Base+Area'. Using the property window, drag & drop the materials 'HairBase' and 'HairArea' to the sub material list.

The level material combines 'HairBase' and 'HairArea' to one single material

9. Having the level material (and the head object) still active, select 'Mapping/Parallel' from the select window's popup menu. Hold down the shift key and draw a small parallel mapping cube over the head. The smaller the mapping, the denser the pattern. Test render the view window and adjust mapping size until the result is suitable.

A pattern of tiny dots mapped to the head

 

Adding the hairs

10. Now we can start adding the actual hairs. Switch to the Geometric Objects tab of the Select window and select the original head object (not the level containing it). Go to the 'Wire' tab of the property window and set 'Texture Quality' to for example '128'. Wait for a while until the 'HairBase' texture pattern appears to the view window. Seeing the hairy area, which was already 3d painted to the head, will guide us where to add the hairs.

11. Zoom in so that the head fills most of the view. Activate the Particle tool from the 'Creation' tab of the toolbar. Select airbrush painting, 2D particles, 'Line Width' = 50, 'Count' = 30 and 'Projection' = 'Surface' from the tool control bar.


'Hairbrush' options

12. Start painting the hair over the head by dragging with the left mouse button over the hairy areas. Rotate the view occasionally so that all areas get painted. Do not worry if hairs are added to the wrong place such as the nose - they can be removed later. On the contrary, brush a fair amount of hairs over the boundary of the hairy area, so that the boundary will have enough hairs. Click 'Accept' when the hair is reasonably dense everywhere.

A suitable amount of hairs is 5000 -10 000. Using a very high amount can make screen refreshing slow and cause memory problems later in ray trace rendering. If this happens, it is good to know that using a high box count in box rendering decreases the memory requirements. You can check the amount of hairs from the property window's spec tab after creating the particle object.

Note: the tool inserts 2d particles perpendicular to the surface. It may happen that the surface normal points to the opposite direction from what was intended for hairs. If this happens, cancel the tool, take a top view and mirror the head. Mirroring inverts the normals. Then start the particle tool again.


'Airbrushing' hair particles onto the head. Note how hairs overlap the actual hair boundary at this stage.

13. Take a side view and set the created '2D particle' object to its 'Edit' state using the view's popup menu. Press the '4' key down and start dragging the lasso selector along the hair boundary. Draw a loop that includes all hairs that lie outside the hair-colored part of the head.


Lasso selecting the hairs that are outside the hairline for deletion

14. If the haircut is symmetrical, you can now click the 'Delete' tool of the tool control bar. Otherwise take a top view and Alt-drag the hairs of the opposite side to remove them from the selection before applying 'Delete'. Then repeat the selection and deletion from the opposite side.

15. Turn off the 'Edit' mode. Make sure the particle object is selected. Go to the property window's 'Spec' tab and select the 'Geometry' sub tab. Pick 'length' from the long attribute list and set it to 0.01 meters (1 cm is pretty good for this kind of simple haircut). Pick 'Diameter1' and set it to a small value like 0.001 (1 mm). Pick 'Diameter2 ' and set it to zero. You may try different values later but these should produce a reasonably good result.

16. Go to the 'Col' tab and set the color of the hairs to the same color as you used for the 'hairbase' material (0.6 0.3 0.2).

17. Test render and adjust the particle properties as required.

 

Coloring the hairs

Most hair types have a subtle color variation. When you grow older (or a software product release becomes badly delayed), gray hairs start appearing. Let us add this property to the hair next.

18. Switch to the Materials tab of the Select window. Select 'New/VSL Material' from the popup.

19. Rename the material as 'HairColor' and using the property window, add the following VSL objects to it:

  • A 'Surface properties' shader. Properties of scanline particles are normally defined in this shader.
  • One 'Float' type variable called 'index'
  • A 'Copy' object that copies UV channel's last sub channel to the index variable, set 'Sub channel 1' = 'Z'.
  • A 'Random' object with the following options:
    • 'Output' = 'Surface:Color' (because this material modifies hair color)
    • 'Input' = 'index'. The random variation is computed from UV channel's third component, which is the index of the hair.
    • 'Operation' = 'Multiply' (random factor scales the original tone)
    • 'Density' = 1 (every hair has a slightly different random color)
    • 'Minimum value' = 1, 'Amplitude' = -0.4 (range 0.6 …1 makes darkest hairs 40 % darker than lightest hairs)
    • check 1D values


A material that randomizes color of hairs

20. Drag & drop the created material to the view window (hair particles should be still selected). A new test rendering finishes this tutorial.

 

Tips and tricks

  • Curved and curly hairs can be modeled using Nurbs curves. Clear the 'Invisible in photorealistic rendering' flag to enable scanline rendering. The 'Spec' tab contains thickness controls for both ends of a curve. 'Lattice/Distribute' and 'Lattice/Paste on Surface' tools can be used for attaching curves into surfaces.
  • The hair color material can also include a shader defining some specular shine. The sample material 'tutorprojects/rendering/shinyhair' contains an example material. It uses the 'Surface:U direction' channel, which contains the direction of hairs.

 
Shiny black hairs